import Vue from 'vue'
import VueRouter from 'vue-router'

import { CHILD_PREFIX } from '@/micro/config.js'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/login'),
    meta: { title: '登录页' },
  },
  {
    path: '/',
    name: 'dashboard',
    redirect: '/Home',
    component: () => import('@/components/layout/index.vue'),
    children: [
      {
        path: '/Home',
        name: 'Home',
        meta: { title: '工作台' },
        component: () => import('../views/Home.vue')
      },
      {
        path: '/about',
        name: 'About',
        component: () => import('../views/About.vue')
      },
    ]
  },
  {
    path: '/one',
    name: 'one',
    component: () => import('@/components/layout/index.vue'),
    children: [
      {
        path: `/app/first-child`,
        name: 'FirstChild',
        children: [
          {
            path: 'home',
            name: 'FirstHome'
          },
          {
            path: 'about',
            name: 'FirstAbout'
          }
        ]
      },
    ]
  },
  {
    path: '/second',
    name: 'second',
    component: () => import('@/components/layout/index.vue'),
    children: [
      {
        path: `/${CHILD_PREFIX}/second-child`,
        name: 'SecondChild',
        children: [
          {
            path: 'home',
            name: 'SecondHome'
          },
          {
            path: 'about',
            name: 'SecondAbout'
          }
        ]
      }
    ]
  },
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
